<template>
  <div>
    <!-- <i class="iconfont">&#xe63b;</i><i class="iconfont">&#xe62c;</i> -->
    <el-menu
      :default-active="activeMenu"
      :collapse="isCollapse"
      :unique-opened="true" 
      class="el-menu-vertical-demo"
      background-color="#304156"
      text-color="#bfcbd9"
      active-text-color="#409eff"
      router>
      <d-menu-item
        v-for="(item, index) in finalURoutes"
        :key="`${index}${item.path}`"
        :item="item"
      />
    </el-menu>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'Index',
  data () {
    return {
      isCollapse: false
    }
  },
  computed: {
    ...mapGetters([
      'finalURoutes'
    ]),
    activeMenu () { // 处理路由页面高亮
      const route = this.$route
      const { meta, path } = route
      // 排除授权页面的高亮
      if (path.indexOf('/system.perm') !== -1) {
        return '/system/role'
      }
      if (meta.activeMenu !== '') {
        return meta.activeMenu
      }
      return path
    }
  },
  methods: {
    changeCollapse () {
      this.isCollapse = !this.isCollapse
    }
  }
}
</script>

<style>

</style>